|
1
|
|
|
const UppyCsvPlugin = class UppyCsvPlugin extends Uppy.Core.Plugin { |
|
2
|
|
|
|
|
3
|
|
|
constructor (uppy, opts) { |
|
4
|
|
|
super(uppy, opts) |
|
5
|
|
|
this.id = opts.id |
|
6
|
|
|
this.type = opts.type |
|
7
|
|
|
this.checkCSV = this.checkCSV.bind(this) |
|
8
|
|
|
|
|
9
|
|
|
this.patientId = opts.patientId |
|
10
|
|
|
this.studyDate = new Date(opts.studyDate) |
|
11
|
|
|
this.suvLo = opts.suvLo |
|
12
|
|
|
this.suvHigh = opts.suvHigh |
|
13
|
|
|
this.useSuv = opts.useSuv |
|
14
|
|
|
this.useCT = opts.useCT |
|
15
|
|
|
this.notify = opts.notify |
|
16
|
|
|
|
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
checkCSV(filesIDs){ |
|
20
|
|
|
console.log(filesIDs) |
|
21
|
|
|
let file = this.uppy.getFile(filesIDs[0]) |
|
22
|
|
|
console.log(file) |
|
23
|
|
|
|
|
24
|
|
|
let csvParser = new PetCtCSVParser(file.data) |
|
25
|
|
|
|
|
26
|
|
|
return csvParser.parseCSV().then( () => { |
|
27
|
|
|
|
|
28
|
|
|
let checkPatientIdentity = csvParser.checkAcquisition(this.patientId, this.studyDate) |
|
29
|
|
|
let checkThreshold = csvParser.checkTMTVThreshold(this.suvLo) |
|
30
|
|
|
this.notify({ |
|
31
|
|
|
Tmtv : csvParser.getTmtvValue(), |
|
32
|
|
|
suvLo : csvParser.getSuvLow(), |
|
33
|
|
|
checkPatientIdentity : checkPatientIdentity, |
|
34
|
|
|
checkThreshold : checkThreshold |
|
35
|
|
|
}) |
|
36
|
|
|
console.log(checkPatientIdentity) |
|
37
|
|
|
console.log(checkThreshold) |
|
38
|
|
|
return (checkPatientIdentity && checkThreshold) |
|
39
|
|
|
}).then((resultCheck)=> { |
|
40
|
|
|
if(!resultCheck) this.uppy.removeFile(file.id) |
|
41
|
|
|
else this.uppy.emit('preprocess-complete', file.id) |
|
42
|
|
|
|
|
43
|
|
|
}) |
|
44
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
install () { |
|
48
|
|
|
this.uppy.addPreProcessor(this.checkCSV) |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
uninstall () { |
|
52
|
|
|
this.uppy.removePreProcessor(this.checkCSV) |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|